package components
{
	import sdk3.c_OBJECT;
	
	import singleton.singleton_storage_local;

	public class groups
	{
		public function groups()
		{
		}
		
		private var c_OBJECT_inst:c_OBJECT = new c_OBJECT();
		
		/** searches for the given group name and returns the given property of the group **/
		public function getGroupWithNameReturnProperty(NAME:String,PROPERTY:String = "ID"):Number
		{
			var result:Number = -1;
			var groups:Array = singleton_storage_local.singleton().groups;
			
			if(c_OBJECT_inst.not_empty(groups))
			{
				for each(var group:Object in groups)
				{
					if(group["NAME"] == NAME)
					{
						result = group["ID"];
						break;
					}
				}
			}
			return result;
		}
		
		/** searches for the given group name and returns the given property of the group **/
		public function getGroupWithNameReturnGroupObject(NAME:String):Object
		{
			var group:Object = null;
			var groups:Array = singleton_storage_local.singleton().groups;
			
			if(c_OBJECT_inst.not_empty(groups))
			{
				for each(group in groups)
				{
					if(NAME == group["NAME"])
					{
						break;
					}
				}
			}
			return group;
		}
		
		/** searches for the given GroupID and returns the given group object **/
		public function getGroupByID(GroupID:String):Object
		{
			var group:Object = null;
			var groups:Array = singleton_storage_local.singleton().groups;
			
			if(c_OBJECT_inst.not_empty(groups))
			{
				for each(group in groups)
				{
					if(GroupID == group["ID"])
					{
						break;
					}
				}
			}
			return group;
		}
	}
}